package cn.iocoder.yudao.module.erp.dal.mysql.purchaseorder;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.purchaseorder.PurchaseOrderGoodsDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 采购单和物品的链接表-多对多关系 Mapper
 *
 * @author maxuxu
 */
@Mapper
public interface PurchaseOrderGoodsMapper extends BaseMapperX<PurchaseOrderGoodsDO> {

    default List<PurchaseOrderGoodsDO> selectListByOrderId(Long orderId) {
        return selectList(PurchaseOrderGoodsDO::getOrderId, orderId);
    }

    default int deleteByOrderId(Long orderId) {
        return delete(PurchaseOrderGoodsDO::getOrderId, orderId);
    }

    default List<PurchaseOrderGoodsDO> selectListByOrderIdGoodsIds(Long linkId, List<Long> goodsIds) {
      return selectList(new LambdaQueryWrapper<PurchaseOrderGoodsDO>()
              .eq(PurchaseOrderGoodsDO::getOrderId, linkId).in(PurchaseOrderGoodsDO::getGoodsId, goodsIds));
    }
}